package com.dingwen.rabcon.service;

import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 注解实现邮件队列消费 <br>
 * <p>
 *     使用{@code @RabbitListener} 可创建队列，可避免在消费端启动时没有创建队列、交换机信息导致的错误
 * </p>
 *
 * @author dingwen
 * 2021.06.17 17:52
 */
//@Component
@RabbitListener(bindings = @QueueBinding(
        value = @Queue(
                value = "topic.queue.email",
                durable = "true",
                autoDelete = "false"
        ),
        exchange = @Exchange(
                value = "topic_exchange_email",
                durable = "true",
                autoDelete = "false"
        ),
        key = "*.email.#"
))
public class TopicConsumerEmailAnnotation {


    @RabbitHandler
    public void receiveMessage(String message){
        System.out.println("message = " + message);
    }
}
